<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../static/public_file/js/jquery.min.js"></script>
    <link rel="stylesheet" href="../../static/personal_center/font_2369197_oqktwkt71s/iconfont.css" media="screen">
    <script type="text/javascript" src="../../static/public_file/js/ModalBox.js"></script>
    <style>
        body, html {
            padding: 0px;
            margin: 0px;
            width: 100%;
            height: 100%;
        }

        .add_background {
            background: #A9A9A9;
        }
        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
            height: 30px;
            line-height: 30px;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
        tr {
            height: 35px;
        }

        th {
            text-align: center;
        }


        .shade {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(36, 36, 36, 0.5);
            display: none;
            z-index: 10000;
        }
        #addForm {
            width: 800px;
            height: 620px;
            background: #F5F5F5;
            position: absolute;
            border: #dfdfdf solid 1px;
            margin: auto;
            border-radius: 3px;
            top: 50%;
            left: 50%;
            /* 实现鼠标拖拽使用css3效果 */
            transform: translate(-50%, -50%);
            display: none;
            z-index: 10100;
            font-size: 0;
        }
        #title {
            display: flex;
            justify-content: space-between;
            box-sizing: border-box;
            padding: 0 10px;
            height: 50px;
            color: #0b0b0b;
            cursor: move;
            /*border: #dfdfdf solid 1px;*/
            width: 100%;background: #f4f7fa;border-top-left-radius: 5px;border-top-right-radius: 5px;
        }
        #addForm1 {
            width: 800px;
            height: 620px;
            background: #F5F5F5;
            position: absolute;
            border: #dfdfdf solid 1px;
            margin: auto;
            border-radius: 3px;
            top: 50%;
            left: 50%;
            /* 实现鼠标拖拽使用css3效果 */
            transform: translate(-50%, -50%);
            display: none;
            z-index: 10100;
            font-size: 0;
        }

        #title1 {
            display: flex;
            justify-content: space-between;
            box-sizing: border-box;
            padding: 0 10px;
            height: 50px;
            color: #0b0b0b;
            cursor: move;
            /*border: #dfdfdf solid 1px;*/
            width: 100%;background: #f4f7fa;border-top-left-radius: 5px;border-top-right-radius: 5px;
        }
        #addForm2 {
            width: 800px;
            height: 600px;
            background: #F5F5F5;
            position: absolute;
            border: #dfdfdf solid 1px;
            margin: auto;
            border-radius: 3px;
            top: 50%;
            left: 50%;
            /* 实现鼠标拖拽使用css3效果 */
            transform: translate(-50%, -50%);
            z-index: 10100;
            font-size: 0;
        }
        #title2 {
            display: flex;
            justify-content: space-between;
            box-sizing: border-box;
            {#padding: 0 10px;#}
            height: 40px;
            color: #0b0b0b;
            cursor: move;
            border-bottom: #dfdfdf solid 1px;
            width: 100%;background: #f4f7fa;border-top-left-radius: 5px;border-top-right-radius: 5px;
        }
        .search {
            width: 300px;
            display: flex;
            float: right;
            margin: 10px 0;
            margin-right: 1%;
            /*border: 1px solid red;*/
        }

        .search input {
            vertical-align: middle;
            float: left;
        / / 左浮动 flex: 4;
            height: 30px;
            width: 230px;
            outline: none;
            border: 1px solid #0070c1;
            box-sizing: border-box;
        / / 盒子模型，怪异IE盒子模型，width = content + border * 2 + padding * 2 padding-left: 10 px;
            border-bottom-left-radius: 3px;
            border-top-left-radius: 3px;
        }

        .search button {
            float: right;
            flex: 1;
            height: 30px;
            width: 70px;
            line-height: 30px;
            background-color: #0070c1;
            color: white;
            border-style: none;
            outline: none;
            border-bottom-right-radius: 3px;
            border-top-right-radius: 3px;
        }

        .search button i {
            font-style: normal;
        }

        .search button:hover {
            font-size: 16px;
        }
        .div_clase{
            display: inline-block;width: 300px;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;
        }
        #loading { background: #fff url(../../static/public_file/images/jiazai.gif) no-repeat scroll center center; height: 100%; width: 100%; background-size: 10%; position: fixed; margin-top: 0px; top: 0px; left: 0px; bottom: 0px; overflow: hidden !important; right: 0px; z-index: 999999;background-color: rgba(255, 255, 255, 0.08);}

    </style>
</head>
<body>
    <div id="loading">
        <div id="loading-center">
        </div>
    </div>

    <div style="width: 100%;height: 40px;background: white;border-bottom: #cfcfcf solid 0.5px;line-height: 40px;color: black;">
        <button onclick="submit_data()" style="float: right;width: 100px;height: 30px;line-height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 0.5px;background-color: #1E90FF;color: white;cursor: pointer;margin-right: 15px;">提交</button>

        <div style="width: 110px;float: right;text-align: center;height: 40px;">
            <button style="line-height: 27px;border-radius: 3px;border: #1E90FF solid 0.5px;width: 100px;height: 30px;margin-top: 5px;background: #1E90FF;color: white;"><a href="javascript:history.go(-1)" style="color: white;">返回</a></button>
        </div>
    </div>

    <div id="DW" style="width: 100%;height: 95%;background: white;">
        <div id="menu_from"
             style="width: 100%;height: 100%;color: #2C3E50;display: inline-block;vertical-align: top;background: white;overflow: auto;">
            <div style="width: 100%;height: 90%;display: inline-block;vertical-align: center;">
                <div style="width: 95%;margin-left: 2.5%;">
                    <table style="width: 100%;margin-top: 20px;">
                        <tr>
                            <td colspan="6" style="width: 95%;margin-left: 2.5%;height: 40px;padding-left: 0.5%;line-height: 40px;border: #cfcfcf solid 1px;text-align: center;">
                                <strong id="form_name" style="letter-spacing: 8px;">快捷用印授权</strong>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="width: 95%;margin-left: 2.5%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #DFDFDF;border: #cfcfcf solid 1px;border-top: none;">基本信息</td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 10%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;padding-right: 1%;">
                                授权科室
                            </td>
                            <td id="department" style="width: 30%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;" onclick="show_model(this.id)" name="{{ obj.company.id }}">{{ obj.company.name }}</td>
                            <td style="width: 10%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;padding-right: 1%;">
                                授权类型
                            </td>
                            <td style="width: 50%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">
                                <select name="" id="shenqing_type" style="width: 100%;height: 100%;border: none;outline: none;">
                                    <option value="0">请选择授权类型</option>
                                    <option value="1" {% if obj.authorization_type == '1' %} selected {% endif %}>法人授权</option>
                                    <option value="2" {% if obj.authorization_type == '2' %} selected {% endif %}>分管授权</option>
                                </select>
                            </td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 10%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;padding-right: 1%;">
                                生效时间
                            </td>
                            <td id="take_effect_time" style="width: 30%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">
                                {{ obj.take_effect_time }}
                            </td>
                            <td style="width: 10%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;padding-right: 1%;">
                                失效时间
                            </td>
                            <td id="lose_efficacy_time" style="width: 50%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">
                                {{ obj.lose_efficacy_time }}
                            </td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 10%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;padding-right: 1%;">
                                分管领导
                            </td>
                            <td id="leader" colspan="3" style="width: 90%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">
                                <select name="" id="select_leader" style="width: 100%;height: 100%;border: none;outline: none;">
                                    <option value="0">请选择分管领导</option>
                                    {% for lea in leader_obj %}
                                        <option value="{{ lea.id }}" {% if obj.select_leader.id == lea.id %} selected {% endif %}>{{ lea.real_name }}</option>
                                    {% endfor %}

                                </select>
                            </td>
                        </tr>
                    </table>
                    <table id="leimuId" style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td colspan="6" style="width: 95%;margin-left: 2.5%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 1px;border-top: none;">
                                授权详情
                                <span style="float: right;padding-right: 10px;color: #00a0e9;cursor: pointer;" onclick="add_other()">添加</span>
                            </td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <th rowspan="2" style="width: 10%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">序号</th>
                            <th style="width: 30%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;" rowspan="2">
                                授权印章
                            </th>
                            <th colspan="2" style="width: 60%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                授权详情
                            </th>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <th style="width: 40%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                授权类目
                            </th>
                            <th style="width: 20%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                授权类型
                            </th>
                        </tr>
                        <tr style="margin-left: 1%;">
                            {% for foo in detail_json %}
                                <td id="leimuxuhao{{ foo.xuhao }}" class="leimuxuhao" style="width: 10%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                    {{ foo.xuhao }}</td>
                                <td style="width: 30%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                    <select name="choose_seal" class="AuthorizedSeal{{ foo.xuhao }}" style="width: 100%;height: 100%;border: none;outline: none;">
                                        {% for seal in seal_obj %}
                                            <option value="{{ seal.id }}" style="text-align: center;height: 35px;" {% if foo.yinzhang ==  seal.id  %} selected {% endif %}>{{ seal.seal_name }}</option>
                                        {% endfor %}
                                    </select>
                                </td>
                                <td class="leimuneirong" id="span_{{ foo.xuhao }}" onclick="model_inline(this.id)" style="width: 40%;border: #cfcfcf solid 0.5px;text-align: left;height: 35px;line-height: 35px;cursor: pointer;">
                                    {% for fo in foo.neirong %}
                                        <p class="AuthorizedCategories{{ foo.xuhao }}" style="width: 100.5%;height: 30px;line-height: 30px;border-bottom: #DFDFDF solid 0.5px;font-size: 14px;">{{ fo.neirong }}</p>
                                    {% endfor %}
                                </td>
                                <td style="width: 20%;border: #cfcfcf solid 0.5px;text-align: left;cursor: pointer;">
                                    <div id="shouquan_type_{{ foo.xuhao }}" style="outline: none;display: -moz-inline-box; display: inline-block;width:95%;cursor: pointer;">
                                        {% for fo in foo.neirong %}
                                            <p class="AuthorizedType{{ foo.xuhao }}" style="width: 100%;height: 30px;line-height: 30px;border-bottom: #DFDFDF solid 0.5px;font-size: 14px;text-align: center;">
                                                {% if fo.type == '1' %}
                                                    一级授权
                                                {% elif fo.type == '2' %}
                                                    二级授权
                                                {% else %}
                                                    三级授权
                                                {% endif %}
                                            </p>
                                        {% endfor %}
                                    </div>
                                </td>
                            {% endfor %}
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div id="addForm3" class="shade">
        <div id="addForm2">
            <div id="title2">
                <div style="line-height: 40px;cursor: move;width: 100%;padding-left: 2%;padding-right: 2%;">
                    <p style="float: left;font-size: 14px;">授权</p>
                    <i class="iconfont icon-quchu" onclick="model_close()" style="cursor: pointer;float: right;"></i>
                </div>
            </div>
            <div style="display: inline-block;width: 100%;height: 480px;border-right: #E8E8E8 solid 1px;font-size: 14px;line-height: 100px;text-align: center;border-bottom: #cfcfcf solid 1px;overflow: auto;">
                <table id="shouqian_table" style="width: 100%;">
                    <tr>
                        <th style="width: 8%;height: 35px;line-height: 35px;text-align: center;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">序号</th>
                        <th style="width: 42%;height: 35px;line-height: 35px;text-align: center;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">授权类目</th>
                        <th style="width: 21%;height: 35px;line-height: 35px;text-align: center;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">授权级别</th>
                        <th style="width: 8%;height: 35px;line-height: 35px;text-align: center;border-bottom: #cfcfcf solid 0.5px;">删除</th>
                    </tr>
                    <tr>
                        <td class="xuhao_td" style="width: 8%;text-align: center;height: 35px;line-height: 35px;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">1</td>
                        <td class="shouquanleixing" style="width: 42%;text-align: left;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;outline: none;" contenteditable="true"></td>
                        <td style="width: 42%;text-align: center;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">
                            <select name="" id="level_1" style="width: 100%;border: none;outline: none;height: 100%;">
                                <option value="1">一级授权</option>
                                <option value="2">二级授权</option>
                                <option value="3">三级授权</option>
                            </select>
                        </td>
                        <td style="width: 8%;text-align: center;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;">
                            <img src="../../static/personal_center/img/02删除-填充.png" alt="" style="width: 25px;height: 25px;vertical-align: top;margin-top: 5px;cursor: pointer;" onclick="remove_category(this)">
                        </td>
                    </tr>
                </table>
                <div style="width: 100%;height: 35px;text-align: center;cursor: pointer;" onclick="add_category()">
                    <img src="../../static/personal_center/img/添加_填充.png" alt="" style="width: 25px;height: 25px;vertical-align: top;margin-top: 5px;cursor: pointer;">
                </div>
            </div>
            <div style="width: 100%;height: 40px;text-align: left;padding-left: 2%;font-size: 14px;border-bottom: #DFDFDF solid 0.5px;color: red;line-height: 40px;">
                备注：一级授权，法人授权；二级授权，分管领导授权；三级授权，科室负责人授权；
            </div>
            <div style="width: 100%;height: 40px;text-align: right;padding-right: 2%;font-size: 14px;">
                <button id="QuerenHsouquan" style="width: 70px;height: 30px;margin-top: 5px;border-radius: 3px;border: #00a0e9 solid 0.5px;background: #00a0e9;color: white;line-height: 30px;">确认</button>
            </div>
        </div>
    </div>

    <div id="addForm1">
        <!-- 标题 -->
        <div id="title1">
            <h5 style="width: 15%;margin-left: 1%;display: inline-block;font-size: 18px;line-height: 0px;">
                协办科室</h5>
            <div class="search"
                 style="vertical-align: center;display: inline-block;text-align: right;margin-left: 35%;font-size: 14px;">
                <input type="text" placeholder="请输入..." name="" id="search_data1" value="">
                <button onclick="search_dep()" id="search_button">搜索</button>
            </div>
            <span onclick="close_models2()"
                  style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i
                    class="iconfont icon-quchu"></i></span>
        </div>
        <hr>
        <div id="processed"
             style="width: 98%;height: 500px;overflow: auto;vertical-align: top;left: 0;padding-left: 2%;">
            {% for company in company_list %}
                <div style="display: inline-block;width: 300px;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;">
                    <input class="check_box1" id="{{ company.id }}" type="radio" name="aaaaaaaaaa"
                           value="{{ company.name }}"> {{ company.name }}
                </div>
            {% endfor %}
        </div>

        <hr>
        <div style="height: 70px;padding-right: 2%;font-size: 14px;">
            <button id="model-affirm2"
                    style="border-radius: 3px;height: 30px;float: right;margin-top: 15px;border: #1E90FF solid 1px;background: #1E90FF;color: white;">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;提&nbsp;交&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </button>
        </div>
    </div>

    <div id="addForm">
        <!-- 标题 -->
        <div id="title">
            <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 0px;font-size: 20px;">
                <h5 style="margin-left: 1%;display: inline-block;font-size: 18px;">选择审批人员</h5>
            </div>

            <div class="search" style="vertical-align: center;display: inline-block;text-align: right;margin-left: 35%;font-size: 14px;">
                <input type="text" placeholder="请输入..." name="" id="search_data" value="">
                <button onclick="search_data()" id="search_button">搜索</button>
            </div>
            <span onclick="close_models1()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
        </div>
        <hr>
        <div style="display: inline-block;width: 30%;height: 350px;border-right: #E8E8E8 solid 1px;">
            <div style="width: 100%;height: 35px;line-height: 35px;padding-left: 2%;color: #0b0b0b;border-bottom: #cfcfcf solid 1px;font-size: 14px;">
                <div id="an_branch"
                     style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;color: #01aaed;">
                    按部门
                </div>
                <div id="an_rank"
                     style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;">按权限
                </div>
                <div id="an_func"
                     style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;">按职能
                </div>
            </div>
            <div id="department_list" style="width: 100%;height: 315px;overflow: auto;">
                <div style="width: 100%;height: 100%;text-align: center;">
                    <img style="width: 30%;height: 30%;margin-top: 35%;"
                         src="../../static/public_file/images/jiazai.gif" alt="">
                </div>
            </div>
        </div>

        <div style="display: inline-block;width: 69.5%;height: 350px;overflow: auto;vertical-align: top;left: 0;font-size: 14px;">
            <table class="table table-hover table-bordered" style="border-collapse: collapse;margin: 0;padding: 0;width: 100%;">
                <thead style="width: 100%;">
                    <tr style="width: 100%;">
                        <th scope="col" style="width: 10%;height: 30px;border: #dfdfdf solid 1px;">
                            <input id="all_select_checkbox" type="checkbox">
                        </th>
                        <th scope="col" style="width: 20%;height: 30px;border: #dfdfdf solid 1px;">序号</th>
                        <th scope="col" style="width: 35%;height: 30px;border: #dfdfdf solid 1px;">姓名</th>
                        <th scope="col" style="width: 35%;height: 30px;border: #dfdfdf solid 1px;">工号</th>
                    </tr>
                </thead>
                <tbody style="overflow: auto;" id="t_table2"></tbody>
            </table>
            <div id="img-display1" style="width: 75%;text-align: center;">
                <div style="margin-top: 10%;">
                    <img src="../../static/public_file/images/page-img/11.jpg" alt="">
                    <p style="margin: 0;padding: 0;vertical-align: top;">暂无数据</p>
                </div>
            </div>
        </div>

        <div style="height: 150px;width: 100%;border-top: #E8E8E8 solid 1px;overflow: auto;">
            <div id="checked-label" style="margin-top: 1%;margin-left: 3%;width: 90%;font-size: 14px;">

            </div>
        </div>
        <hr>
        <div style="height: 70px;padding-right: 2%;font-size: 14px;">
            <button onclick="choose_people()" id="model-affirm" style="border-radius: 3px;height: 30px;float: right;margin-top: 15px;border: #1E90FF solid 1px;background: #1E90FF;color: white;">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;提&nbsp;交&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </button>
        </div>
    </div>

    <script language="javascript" src="../../static/personal_center/js/jquery-1.4.4.min.js"></script>
    <script language="javascript" src="../../static/personal_center/js/jquery.jqprint-0.3.js"></script>
{#    <script type="text/javascript" src="../../static/public_file/other/jquery.js"></script>#}
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script> <!-- 改成你的路径 -->
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
        };

        lay('#version').html('-v' + laydate.v);

        //执行一个laydate实例
        laydate.render({
            elem: '#take_effect_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#lose_efficacy_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        function model_inline(this_eve) {
            var shouquanleixing_list = document.getElementsByClassName("shouquanleixing");
            for (var t=0; t<shouquanleixing_list.length; t++) {
                shouquanleixing_list[t].innerHTML='';
             }
            document.getElementById("addForm3").style.display="table-row";
            document.getElementById("QuerenHsouquan").setAttribute("onclick", "queren_hsouquan('"+this_eve+"')")
        }

        function model_close() {
            document.getElementById("addForm3").style.display="none";
        }

        let title2 = document.querySelector("#title2");
        let addForm2 = document.querySelector("#addForm2");
        title2.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm2.offsetLeft;
            let y = e.pageY - addForm2.offsetTop;


            document.addEventListener("mousemove", move);
            function move(e) {
                addForm2.style.left = e.pageX - x + 'px';
                addForm2.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function remove_category(obj) {
            var trNode = $(obj).parent().parent();
            trNode.remove();
            var tr_lenght = document.getElementsByClassName("shouquanleixing").length;
            var xuhao_td = document.getElementsByClassName("xuhao_td")

            for (var i=0; i<tr_lenght; i++) {
                xuhao_td[i].innerText = i+1;
            }
        }

        function add_category() {
            var tr_lenght = document.getElementsByClassName("shouquanleixing").length+1;
            var html_str = `
                    <tr>
                        <td class="xuhao_td" style="width: 8%;text-align: center;height: 35px;line-height: 35px;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">`+String(tr_lenght)+`</td>
                        <td class="shouquanleixing" style="width: 42%;text-align: left;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;" contenteditable="true"></td>
                        <td style="width: 42%;text-align: center;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;border-right: #cfcfcf solid 0.5px;">
                            <select name="" id="level_`+String(tr_lenght)+`" style="width: 100%;border: none;outline: none;height: 100%;">
                                <option value="1">一级授权</option>
                                <option value="2">二级授权</option>
                                <option value="3">三级授权</option>
                            </select>
                        </td>
                        <td style="width: 8%;text-align: center;height: 35px;line-height: 35px;padding-left: 0.5%;border-bottom: #cfcfcf solid 0.5px;">
                            <img src="../../static/personal_center/img/02删除-填充.png" alt="" style="width: 25px;height: 25px;vertical-align: top;margin-top: 5px;cursor: pointer;" onclick="remove_category(this)">
                        </td>
                    </tr>
            `
            $("#shouqian_table").append(html_str);
        }

        function add_other() {
            var leimuxuhao_count =  document.getElementsByClassName("leimuxuhao").length + 1;
            var html = `<tr style="margin-left: 1%;">
                            <td id="leimuxuhao`+leimuxuhao_count+`" class="leimuxuhao" style="width: 10%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">`+leimuxuhao_count+`</td>
                            <td style="width: 30%;border: #cfcfcf solid 0.5px;text-align: center;height: 35px;line-height: 35px;">
                                <select name="choose_seal" class="AuthorizedSeal1" style="width: 100%;height: 100%;border: none;outline: none;">
                                    {% for seal in seal_obj %}
                                        <option value="{{ seal.id }}" style="text-align: center;height: 35px;">{{ seal.seal_name }}</option>
                                    {% endfor %}
                                </select>
                            </td>
                            <td class="leimuneirong" id="span_`+leimuxuhao_count+`" onclick="model_inline(this.id)" style="width: 40%;border: #cfcfcf solid 0.5px;text-align: left;height: 35px;line-height: 35px;cursor: pointer;color: #cccccc;">
                                请填写授权类目
                            </td>
                            <td style="width: 20%;border: #cfcfcf solid 0.5px;text-align: left;cursor: pointer;">
                                <div id="shouquan_type_`+leimuxuhao_count+`" style="outline: none;display: -moz-inline-box; display: inline-block;width:80%;cursor: pointer;">
                                </div>
                                <span onclick="remove_time_adress(this)" style="color: red; cursor: pointer; display: inline-block;">删除</span>
                            </td>
                        </tr>`
            $("#leimuId").append(html);
        }

        function remove_time_adress(obj) {
            var trNode = $(obj).parent().parent();
            trNode.remove();
            var xuhao_list = document.getElementsByClassName("leimuxuhao");
            for (var i=0; i<xuhao_list.length; i++) {
                xuhao_list[i].innerText=i+1
            }
        }

        function close_models2() {
            document.getElementById("addForm1").style.display = "none";
        }

        function show_model(ele_id) {
            document.getElementById("addForm1").style.display = "table-row";
            document.getElementById("model-affirm2").setAttribute("onclick", "summit_val('"+ele_id+"')")
        }

        function search_dep(search_data) {
            var search_keyword = document.getElementById(search_data).value;
            var processed = document.getElementById("processed");
            processed.innerHTML = "";
            var company_list = {{ company_list | safe }}
            for (var h = 0; h < company_list.length; h++) {
                if (company_list[h]["name"].indexOf(search_keyword) !== -1) {
                    console.log(company_list[h]["name"])
                    var div_tag = document.createElement("div");
                    div_tag.className = "div_clase";
                    div_tag.style.fontSize = "14px";
                    div_tag.innerHTML = '<input class="check_box" id="' + company_list[h]["id"] + '" name="select_dapart" value="' + company_list[h]["name"] + '" type="radio"> ' + company_list[h]["name"];
                    processed.appendChild(div_tag)
                }
            }
        }

        function summit_val(ele_id) {
            var cleck_box_list = document.getElementsByClassName("check_box1");
            var xuanzhong_id = ''
            var xuanzhong_value = ''
            for (var t = 0; t < cleck_box_list.length; t++) {
                if (cleck_box_list[t].checked) {
                    xuanzhong_id = cleck_box_list[t].id
                    xuanzhong_value = cleck_box_list[t].value
                }
            }
            document.getElementById(ele_id).innerText = xuanzhong_value;
            document.getElementById(ele_id).setAttribute("name", xuanzhong_id)
            document.getElementById(ele_id).style.color="#1C1C1C"
            document.getElementById("addForm1").style.display = "none";
        }

        function queren_hsouquan(this_eve) {
            document.getElementById(this_eve).innerText = "";
            document.getElementById(this_eve).style.color = "";
            document.getElementById("shouquan_type_"+this_eve.split("_")[1]).innerText = "";
            var xuhao_td = document.getElementsByClassName("xuhao_td");
            var shouquanleimu_list = document.getElementsByClassName("shouquanleixing");
            var shouquan_count = 1;var category_list = [];
            for (var i=0; i<shouquanleimu_list.length; i++) {
                var id_name = 'level_' + String((i+1));
                var TypeS = document.getElementById(id_name).value;
                if (String(TypeS) === "undefined") {
                    alert("请选择授权类目！");
                    return false
                }
                category_list.push({"xuhao": xuhao_td[i].innerText, "category": shouquanleimu_list[i].innerText, "Type": TypeS})
                shouquan_count += 1
            }

            for (var t=0; t<category_list.length; t++) {
                var p_str = `<p class="AuthorizedCategories`+this_eve.split("_")[1]+`" style="width: 100.5%;height: 30px;line-height: 30px;border-bottom: #DFDFDF solid 0.5px;font-size: 14px;">`+category_list[t]['category']+`</p>`
                var pinjie_id = "#"+this_eve
                $(pinjie_id).append(p_str)
                var pinjie_type = "#shouquan_type_"+this_eve.split("_")[1];
                if (category_list[t]['Type'] === '1') {
                    var categoryType = "一级授权";
                } else if (category_list[t]['Type'] === '2') {
                    categoryType = "二级授权";
                }else {
                    categoryType = "三级授权";
                }
                var p_tag_str = `<p class="AuthorizedType`+this_eve.split("_")[1]+`" style="width: 100%;height: 30px;line-height: 30px;border-bottom: #DFDFDF solid 0.5px;font-size: 14px;text-align: center;">`+categoryType+`</p>`;
                $(pinjie_type).append(p_tag_str)
            }
            model_close()
        }

        function submit_data() {
            var seal_check = document.getElementsByName("choose_seal");
            var leimuxuhao_list = document.getElementsByClassName("leimuxuhao")
            var detail_json = []
            for (var i=0; i<seal_check.length; i++) {
                var neirong = document.getElementsByClassName("AuthorizedCategories"+leimuxuhao_list[i].innerText)
                var AuthorizedType = document.getElementsByClassName("AuthorizedType"+leimuxuhao_list[i].innerText)
                var leirong_list = []
                for (var tt=0; tt<neirong.length; tt++) {
                    var Type_S = AuthorizedType[tt].innerText;
                    if (Type_S === "一级授权") {
                        var Type_Number = "1"
                    }else if (Type_S === "二级授权") {
                        Type_Number = "2"
                    }else {
                        Type_Number = "3"
                    }
                    leirong_list.push({"neirong": neirong[tt].innerText, "type": Type_Number})
                }
                detail_json.push({"xuhao": leimuxuhao_list[i].innerText, "yinzhang": parseInt(seal_check[i].value), 'neirong': leirong_list})
            }

            var authorization_type = document.getElementById("shenqing_type").value;
            var department = $("#department").attr("name");
            var conferee = document.getElementById('conferee').value;
            var take_effect_time = document.getElementById('take_effect_time').innerText;
            var lose_efficacy_time = document.getElementById('lose_efficacy_time').innerText;
            var select_leader = document.getElementById('select_leader').value;
            console.log("detail_json=" + JSON.stringify(detail_json)+"&authorization_type="+authorization_type+"&department="+String(department)+"&conferee="+conferee)
            {#document.getElementById("loading").style.display = "inline-block";#}
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/system-setup/add_empower", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id={{ obj.id }}&detail_json=" + JSON.stringify(detail_json)+"&authorization_type="+authorization_type+"&department="+String(department)+"&conferee="+conferee+"&lose_efficacy_time="+lose_efficacy_time+"&take_effect_time="+take_effect_time+"&select_leader="+select_leader);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("修改成功");
                            window.location = "AuthorizationUseSeal.html";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
             };
        }
    </script>
</body>
</html>